﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MultipleQueue.Simulation;

namespace MultipleQueue
{
    public partial class PerformanceMeasures : Form
    {
        private SimulationManager simManager;

        public PerformanceMeasures(ref SimulationManager manager)
        {
            InitializeComponent();
            this.WindowState = FormWindowState.Maximized;
            this.simManager = manager;
            this.PerformanceValues();
            this.numericUpDownServer.Maximum = manager.Servers.Count;
        }

        private void PerformanceValues()
        {
            //this.simManager = new SimulationManager();
            this.dataGridAverageUtilization.DataSource = this.simManager.AverageServiceTime;
            this.dataGridCustomersTable.DataSource = this.simManager.CustomersTable;
            this.dataGridIdleTime.DataSource = this.simManager.IdleServerProbability;
            this.lblAverageWaitTime.Text = this.simManager.AverageWaitingTime.ToString();
            this.lblWaitProbability.Text = this.simManager.ProbabilityOfWait.ToString();
        }

        private void btnCustomersQueue_Click(object sender, EventArgs e)
        {
            QueueChart chart = new QueueChart(ref simManager);
            chart.ShowDialog();
        }

        private void btnDelayChart_Click(object sender, EventArgs e)
        {
            DelayHistogram delayHist = new DelayHistogram(ref simManager);
            delayHist.ShowDialog();
        }

        private void btnServerBusy_Click(object sender, EventArgs e)
        {
            SeverBusyTimeGraph serverBusy = new SeverBusyTimeGraph(ref simManager, (int)this.numericUpDownServer.Value);
            serverBusy.ShowDialog();
        }
    }
}
